home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 6 / tc_xmem.zip / XMEM.DOC < prev    next >
Text File  |  1987-10-21  |  5KB  |  106 lines

  1. XMEM - Access to 80286/386 Extended Memory from Turbo C
  2.  
  3. (c) 1987 Micro Consulting Associates
  4.          868 Ashford Ave., Suite 6B
  5.      San Juan, P.R. 00907-1018
  6.          (809) 721-8470
  7.  
  8. The XMEM routine is included here in .OBJ format, small memory model
  9. only. Source is available for the routine for a $30 donation. The source
  10. code is in assembly language (MASM 4.0) and will allow you to modify the
  11. routine for use with other memory models. Along with the source code for
  12. XMEM.OBJ, you will also get a copy of TC_CPUID.ASM, the source code to
  13. the TC_CPUID.OBJ module. This routine allows you to identify any Intel
  14. processor, from 8088 to 80386, from software.
  15.  
  16. TC_XMEM.C is a demonstration program which shows you how to use XMEM.
  17. There is a full example of how to call the routine along with some
  18. techniques which might prove to be useful if you intend to incorporate
  19. the routine into your programs.
  20.  
  21. XMEM is a Turbo C callable routine that allows you to transfer up to
  22. 64k of data to/from low DOS memory (below 1 meg boundary) and high
  23. memory (above the 1 meg boundary).
  24.  
  25. THIS ROUTINE IS FOR USE ON PC/AT OR 80386 AND FULL COMPATIBLES ONLY!
  26.  
  27. THE CONTENTS OF ANY RAMDISK IN EXTENDED MEMORY MAY BE DESTROYED!
  28.  
  29. Calling format is:
  30.  
  31. int xmem(source_seg,source_offset,source_meg,dest_seg,dest_offset,
  32.     dest_meg,size);
  33. int source_seg,source_offset,dest_seg,dest_offset,size;
  34. char source_meg,dest_meg;
  35.  
  36. Where:
  37.  
  38. source_seg    : Segment where data is located
  39. source_offset : Offset within segment where data is located
  40. source_meg    : Megabyte boundary for source data, min is 0 (within DOS
  41.                 memory), max is 15 (F hex), a value of 1 or more means
  42.                 data is in extended memory.
  43. dest_seg      : Segment where data is to be transferred to
  44. dest_offset   : Offset within segment where data is to be transferred to
  45. dest_meg      : Same as source_meg, but locates megabyte boundary where
  46.                 data is to be transferred to
  47. size          : Number of bytes to transfer, min is 1, max is 64k
  48.  
  49. Returns:
  50.  
  51.     0  = successful transfer
  52.     1  = parity error encountered during transfer
  53.     2  = exception interrupt error during transfer
  54.     3  = 8042 slave processor failure (gate 20 not enabled)
  55.           4  = <undefined>
  56.           5  = Invalid megabyte boundary, outside range (0 to 15)
  57.     6  = Not enough extended memory
  58.     7  = No extended memory installed
  59.  
  60. Now that you made it through all that, let's ask a simple question:
  61.  
  62.     What do I do with all of this?
  63.  
  64. You can store data for your programs in expanded memory WITHOUT getting
  65. into EMS or EEMS hardware or software (and therefore making your customers
  66. happy about not having to shell out bucks to make full use of your program.)
  67. Also, it gives you much more flexibility beacuse you do not have to conform
  68. to either the EMS or EEMS standards or to their limitations, such as the page
  69. sizes. You also don't have to worry about changes in the EMS or EEMS specs
  70. or their respective drivers because the service routines for this interrupt
  71. are burned into the ROM! One disadvantage is that after a while your
  72. clock will get a little out of whack due to your taking away its precious
  73. interrupts, but that is certainly not an insurmountable problem for
  74. an enterprising programmer like YOU, is it? (Actually, the trick to that
  75. is to play with the 8253 timer to make up for the lost clock, but I'm under
  76. a non-disclosure agreement from Ronco Vaporware Products, Inc., etc...)
  77.  
  78. Some ideas for this are:
  79.  
  80. 1) Overlay managers that use expanded memory to store and quickly
  81.    access code in overlays (16 megabytes of overlay code, wow!)
  82.  
  83. 2) Spreadsheets that want to make use of up to 16 megabytes of
  84.    storage space (talk about your power-user blowing a fuse!)
  85.  
  86. 3) Sorting massive amounts of data FAST! (anybody for sorting
  87.    the NYC telephone directory?)
  88.  
  89. ... and so on.
  90.  
  91. If you wanted to implement the processes defined here in an overlay
  92. manager, for example, you could take all the overlay code and data at the
  93. beginning of execution and store it in blocks in extended memory.
  94. Then, every time you needed an overlay, you just do a transfer from
  95. extended memory into the overlay area. Mem moves are a heck of a lot
  96. faster than disk moves, so, even though you spend a little time setting
  97. up, you more than make up for it in time saved on disk accesses.
  98.  
  99. The disadvantages of this method for storing data are that it is up to you
  100. to keep track of what is where (though that should not be hard to do, just
  101. use double word variables to store locations of code or data blocks). Also,
  102. you have to adjust the clock once in a while because all interrupts are
  103. disabled or set to dummy handlers during operations in protected mode...
  104. Oh, yes, if you use this you just made your program 80286- or 80386-
  105. specific. No big deal about that, though.
  106.